#ifndef __PRIORITY_QUEUE_H__
#define __PRIORITY_QUEUE_H__

typedef struct task
{
    int id;
    int priority;
    long time;
    int status;
    void (*func)(void *);
    void *args;
} Task;

// typedef int Element;
typedef Task Element;
typedef int (*Compare)(Element, Element);
typedef void (*Swap)(Element *, Element *);

typedef struct Heap
{
    Compare cmp;   // 优先级比较函数
    Swap swap;     // 元素交换函数
    int capacity;  // 堆容量
    int size;      // 堆中元素个数
    Element *data; // 堆数据数组
} Heap, *PriorityQueue;

typedef enum
{
    PRIORITYQUEUE_CLOSE = 0, // 关闭
    PRIORITYQUEUE_DEBUG = 1, // 调试
    PRIORITYQUEUE_ERROR = 2, // 错误
    PRIORITYQUEUE_ALL = 3    // 全部
} PRIORITYQUEUE_DEBUG_LEVEL;

void priority_queue_setdebug_leval(PRIORITYQUEUE_DEBUG_LEVEL level);
PriorityQueue priority_queue_init(int capacity);
void priority_queue_destroy(PriorityQueue pq);
int priority_queue_insert(PriorityQueue pq, Element e);
Element priority_queue_extract(PriorityQueue pq);
void priority_queue_test_main(void *arg);

#endif /*__PRIORITY_QUEUE_H__*/